﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using S7.Net;

namespace MyWPF.Models.S7
{
    public class S7Helper : IS7
    {
        Plc plc;

        public bool Link(S7Context PlcConfig)
        {
            plc = new Plc(PlcConfig.CpuType,PlcConfig.IP,0,0);
            plc.Open();
            return true;
        }

        public byte[] ReadBytes(int DB, int StartAdr, int Length)
        {
            object value = plc.Read(DataType.DataBlock, DB, StartAdr, VarType.Byte, Length);
            return (byte[])value;
        }
    }
}
